package com.situ.day10;

import java.lang.reflect.Array;

public final class ArrayUtil {
	public final static int max(int[] array){
		int max = array[0];
		for (int i = 1; i < array.length; i++) {
			if (max < array[i]) {
				max = array[i];
			}
		}
		return max;
	}
	
	public final static int min (int[] array){
		int min = array[0];
		for (int i = 1; i < array.length; i++) {
			if (min > array[i]) {
				min = array[i];
			}
		}
		return min;
	}
	
	public final static void maopao(int[] array){
		for (int i = 1; i <= array.length - 1; i++) {
			for (int j = 0; j < array.length - i; j++) {
				if (array[j] > array[j + 1] ) {
					swap(array, j, j+1);
				}
			}
		}
	}

	private static void swap(int[] array, int x,int y) {
		int temp = array[x];
		array[x] = array[y];
		array[y] = temp;
	}
}
